#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define maxn 100100
using namespace std;
long long tree[maxn<<2];
long long lazy[maxn<<2];
long long a[maxn];
void build(int rt,int s,int e)
{
	if(s==e) 
	{
		tree[rt] = a[s];
		return ;
	}
	int mid = (s+e)>>1;
	int l_node = rt*2;
	int r_node = rt*2+1;
	build(l_node,s,mid);
	build(r_node,mid+1,e);
	tree[rt] = tree[l_node]+tree[r_node];
}
long long query(int rt,int s,int e,int l,int r)
{
	//printf("%d %d %d %d\n",s,e,l,r);
	if(l<=s&&e<=r) 
	{	
		printf("*****\n");
		return tree[rt];
	}
	int mid = (s+e)>>1;
	//printf("mid = %d\n",mid);
	int l_node = rt*2;
	int r_node = rt*2+1;
	if(lazy[rt])
	{
		lazy[l_node] = lazy[rt];
		lazy[r_node] = lazy[rt];
		lazy[rt] = 0;
		tree[l_node] += lazy[l_node]*(mid-s+1);
		tree[r_node] += lazy[r_node]*(e-mid+1+1); 
	}
	long long  sum = 0;
	if(l<=mid) 
	{
		//printf("%d %d\n",l,mid);
		sum += query(l_node,s,mid,l,r);
	}
	if(r>mid) sum += query(r_node,mid+1,e,l,r);
	tree[rt] = tree[l_node]+tree[r_node];
	return sum;
}
void Dupdate(int rt,int s,int e,int idx,int val)
{
	if(s==idx&e==idx)
	{
		tree[rt] += val;
		return ;
	}
	int mid = (s+e)>>1;
	int l_node = rt*2;
	int r_node = rt*2+1;
	if(idx<=mid) Dupdate(l_node,s,mid,idx,val);
	else Dupdate(r_node,mid+1,e,idx,val);
	tree[rt] = tree[l_node]+tree[r_node];
}
void Qupdate(int rt,int s,int e,int l,int r,int val)
{
	if(l<=s&&e<=r)
	{
		lazy[rt] += val;
		tree[rt] += (e-s+1)*val;
		return ;
	}
	int mid = (s+e)>>1;
	int l_node = rt*2;
	int r_node = rt*2+1;
	if(lazy[rt])
	{
		lazy[l_node] = lazy[rt];
		lazy[r_node] = lazy[rt];
		lazy[rt] = 0;
		tree[l_node] += lazy[l_node]*(mid-s+1);
		tree[r_node] += lazy[r_node]*(e-mid+1+1); 
	}
	if(l<=mid) Qupdate(l_node,s,mid,l,r,val);
	if(r>mid) Qupdate(r_node,mid+1,e,l,r,val);
	tree[rt] = tree[l_node]+tree[r_node];
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n,op;
		scanf("%d %d",&n,&op);
		for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
		build(1,1,n);
		for(int i = 1;i<=op;i++)
		{
			printf("%d\n",i);
			char p;
			int l,r,val;
			scanf(" %c",&p);
			if(p=='A') 
			{
				scanf("%d %d",&val,&r);
				Dupdate(1,1,n,r,val);
			}
			else if(p=='Q')
			{
				scanf("%d %d",&l,&r);
				printf("%I64d\n",query(1,1,n,l,r));
			}
			else 
			{
				scanf("%d %d %d",&l,&r,&val);
				Qupdate(1,1,n,l,r,val);
			}
		}
	}
}
